<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>User List</title>
</head>
<body>
<h1>User List</h1>
<a href="/users/new">Create New User</a>

<!-- 删除所有用户的按钮 -->
<form th:action="@{/users/deleteAll}" method="post" style="display:inline;">
    <button type="submit" onclick="return confirm('Are you sure you want to delete all users? This action cannot be undone.');">Delete All Users</button>
</form>

<table border="1">
    <thead>
    <tr>
        <th>ID</th>
        <th>Name</th>
        <th>Age</th>
        <th>Actions</th>
    </tr>
    </thead>
    <tbody>
    <tr th:each="user : ${users}">
        <td th:text="${user.id}"></td>
        <td th:text="${user.name}"></td>
        <td th:text="${user.age}"></td>
        <td>
            <a th:href="@{'/users/' + ${user.id} + '/edit'}">Edit</a>
            <form th:action="@{'/users/' + ${user.id}}" method="post" style="display:inline;">
                <input type="hidden" name="_method" value="delete"/>
                <button type="submit">Delete</button>
            </form>
        </td>
    </tr>
    </tbody>
</table>
</body>
</html>
